﻿using System.Collections.Generic;

namespace UnknowWorld.CardGame
{
    /// <summary>
    /// 敌人数据
    /// </summary>
    public class Enemey : Character
    {
        /// <summary>
        /// 编号
        /// </summary>
        public string Key { get; set; }
        /// <summary>
        /// 敌人数据
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 等级
        /// </summary>
        public int Level { get; set; }
        /// <summary>
        /// 简介
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 图片地址
        /// </summary>
        public string PicAddress { get; set; }
        /// <summary>
        /// 等级生命值缩放比例
        /// </summary>
        public float LevelHealthScale { get; set; }
        /// <summary>
        /// 等级魔法值缩放比例
        /// </summary>
        public float LevelMagicScale { get; set; }
        /// <summary>
        /// 等级耐力值缩放比例
        /// </summary>
        public float LevelStaminaScale { get; set; }

        /// <summary>
        /// 等级血量
        /// </summary>
        /// <returns></returns>
        int LevelHealth()
        {
            return (int)(Level * (1 + LevelHealthScale) * MaxHealth);
        }

        /// <summary>
        /// 等级魔力
        /// </summary>
        /// <returns></returns>
        int LevelMagic()
        {
            return (int)(Level * (1 + LevelMagicScale) * MaxMagic);
        }

        /// <summary>
        /// 等级耐力
        /// </summary>
        /// <returns></returns>
        int LevelStamina()
        {
            return (int)(Level * (1 + LevelStaminaScale) * MaxStamina);
        }

        /// <summary>
        /// 克隆Enemey
        /// </summary>
        /// <returns></returns>
        public Enemey Clone()
        {
            Enemey cloneEnemey = new Enemey()
            {
                Key = this.Key,
                Name = this.Name,
                Description = this.Description,
                PicAddress = this.PicAddress,
                MaxHealth = this.LevelHealth(),
                Health = MaxHealth,
                MaxMagic = this.LevelMagic(),
                Magic = MaxMagic,
                MaxStamina = this.LevelStamina(),
                Stamina = MaxStamina,
                Level = this.Level,
                Cards = this.Cards,
                HandCardCount = this.HandCardCount,
                LevelHealthScale = this.LevelHealthScale,
                LevelMagicScale = this.LevelMagicScale,
                LevelStaminaScale = this.LevelStaminaScale,
            };
            return cloneEnemey;
        }

        /// <summary>
        /// 初始化卡组
        /// </summary>
        public void LoadInitCard()
        {
            for (int i=0;i< Cards.Count;i++)
            {
                var cd = CardPool.Instance.CardByKey(Cards[i].Key);
                cd.Level = Cards[i].Level;
                Cards[i] = cd;
            }
        }
    }
}